Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-161625: fix mas:pending event on requestUpdate #3388

Merged
merged 1 commit into from
Jan 20, 2025
Merged

Conversation

3ch023
Copy link
Contributor

@3ch023 3ch023 commented Dec 17, 2024

when requestUpdate on MAS inline-price or checkout-link is called the 'mas:resolved' event is dispatched twice.
this PR is fixing first event to be 'mas:pending' and it is followed by a single 'mas:resolved' or 'mas:failed'

added nala tests to cover this too.

Test URLs:

Copy link
Contributor

aem-code-sync bot commented Dec 17, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link
Contributor

aem-code-sync bot commented Dec 17, 2024

Page Scores Audits Google
📱 /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.46%. Comparing base (6eb0401) to head (a2148d7).
Report is 3 commits behind head on stage.

Additional details and impacted files
@@            Coverage Diff             @@
##            stage    #3388      +/-   ##
==========================================
- Coverage   96.47%   96.46%   -0.02%     
==========================================
  Files         258      258              
  Lines       60150    60135      -15     
==========================================
- Hits        58029    58007      -22     
- Misses       2121     2128       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice 👍

name: '@MAS-DOCS-checkout-link',
path: '/libs/features/mas/docs/checkout-link.html',
browserParams: '?theme=dark',
tags: '@mas-docs @checkout-link @commerce @smoke @regression @milo',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need mas- prefix for the tags?

Copy link
Contributor Author

@3ch023 3ch023 Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will ask @afmicka
i have a feeling that these tags should be unique for whole milo repo, so if we want an ability to run only our mas docs tests - then it should be @mas-docs, if we want to run 'all' docs - @docs
i am not sure which it should be

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, those tags are global, and docs would be ambiguous

@@ -153,6 +153,8 @@ export class MasElement {
this.state = STATE_FAILED;
this.update();
this.log?.error('Failed:', { element: this.wrapperElement, error });
// Allow calling code to perform sync updates of this element
// before notifying observers about state change
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, setImmediate is deprecated, should we try it with setTimeout(callback, 0) by this occasion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i refactored it to just call notify function where we need to call it.. imo this thread breaks are making comprehension harder

@@ -166,7 +168,8 @@ export class MasElement {
if (options) this.options = options;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you can listen the very first mas:pending event.
If you try to register an even listener for a <span is="price" data-wcs-osi="xyz">/span>, it is possible that, the pending event will be dispatched before you register.
To check. I would really remove pending all together, and consider the default state as pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it, agree it's an unnessary event

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would somewhere here though add some debug log to mention that element is pending resolution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, thx

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

selectOffers(await promise, options),
options,
version,
);
this.masElement.notify();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic is handled at mas-element level(*), the custom elements (we may have more in the future) should not know how / when to notify.

(*) https://github.com/adobecom/milo/pull/3388/files#diff-b76179f008b9c485066e722d9e2b9265ccdbfe9d5abb33507d5ab8424e7a45b5L207-L219

Copy link
Contributor Author

@3ch023 3ch023 Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, i moved it back into mas-element

@@ -162,13 +162,15 @@ export class CheckoutLink extends HTMLAnchorElement {
{ ...extraOptions, ...options },
this,
);
return this.renderOffers(
const result = this.renderOffers(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as for inline-price

@@ -166,7 +168,8 @@ export class MasElement {
if (options) this.options = options;
this.state = STATE_PENDING;
this.update();
setImmediate(() => this.notify());
// immediately notify observers about state change
this.notify();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't we even remove notification for pending state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did that, thx

@@ -166,7 +168,8 @@ export class MasElement {
if (options) this.options = options;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would somewhere here though add some debug log to mention that element is pending resolution

name: '@MAS-DOCS-checkout-link',
path: '/libs/features/mas/docs/checkout-link.html',
browserParams: '?theme=dark',
tags: '@mas-docs @checkout-link @commerce @smoke @regression @milo',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, those tags are global, and docs would be ambiguous

@@ -148,6 +148,7 @@ export class MasElement {
if (options) this.options = options;
this.state = STATE_PENDING;
this.update();
this.log?.debug('Pending:', { element: this.wrapperElement });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this has any performance impact, this it needs to kind of serialize the wrapperElement.

Copy link
Contributor

@yesil yesil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nala tests failing?

Copy link
Contributor

Reminder to set the Ready for Stage label - to queue this to get merged to stage & production.

@Roycethan
Copy link

Verified, Regressions covered

@Roycethan Roycethan added verified PR has been E2E tested by a reviewer Ready for Stage labels Dec 20, 2024
@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 2, 2025

Skipped 3388: "MWPW-161625: fix mas:pending event on requestUpdate" due to file "libs/deps/mas/commerce.js" overlap. Merging will be attempted in the next batch

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 7, 2025

Skipped 3388: "MWPW-161625: fix mas:pending event on requestUpdate" due to file "libs/deps/mas/mas.js" overlap. Merging will be attempted in the next batch

@Roycethan
Copy link

@3ch023 Plz resolve conflicts in this PR to merge, thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

@adobecom adobecom deleted a comment from milo-pr-merge bot Jan 10, 2025
@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 13, 2025

Skipped 3388: "MWPW-161625: fix mas:pending event on requestUpdate" due to file "libs/deps/mas/commerce.js" overlap. Merging will be attempted in the next batch

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 14, 2025

Error merging 3388: MWPW-161625: fix mas:pending event on requestUpdate Pull Request is not mergeable

@mokimo
Copy link
Contributor

mokimo commented Jan 14, 2025

@3ch023 seems like the merge of yesterday, lead to conflicts today

This branch has conflicts that must be resolved
libs/deps/mas/commerce.js
libs/deps/mas/mas.js
libs/deps/mas/merch-card.js
libs/features/mas/dist/mas.js

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 14, 2025

Skipped 3388: "MWPW-161625: fix mas:pending event on requestUpdate" due to file "libs/deps/mas/merch-card-collection.js" overlap. Merging will be attempted in the next batch

@3ch023
Copy link
Contributor Author

3ch023 commented Jan 14, 2025

@3ch023 seems like the merge of yesterday, lead to conflicts today

This branch has conflicts that must be resolved
libs/deps/mas/commerce.js
libs/deps/mas/mas.js
libs/deps/mas/merch-card.js
libs/features/mas/dist/mas.js

I want to automate this
https://github.com/orgs/adobecom/discussions/3443

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 14, 2025

Skipped merging 3388: MWPW-161625: fix mas:pending event on requestUpdate due to failing checks

@mokimo
Copy link
Contributor

mokimo commented Jan 14, 2025

@3ch023 you might need to rebase to stage inorder for the nala tests to run through. Not sure if its the same tests @afmicka told me to rebase for though 😁

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 15, 2025

Skipped merging 3388: MWPW-161625: fix mas:pending event on requestUpdate due to failing checks

1 similar comment
@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jan 16, 2025

Skipped merging 3388: MWPW-161625: fix mas:pending event on requestUpdate due to failing checks

@milo-pr-merge milo-pr-merge bot merged commit 965a8c6 into stage Jan 20, 2025
14 checks passed
@milo-pr-merge milo-pr-merge bot deleted the MWPW-161625 branch January 20, 2025 09:25
@milo-pr-merge milo-pr-merge bot mentioned this pull request Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce Ready for Stage verified PR has been E2E tested by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants